{php include wl_template('common/header');}
{if $_GPC['op']!='data'}
<ul class="nav nav-tabs">
	<li {if $_GPC['op']=='account_display'}class="active"{/if}><a href="{php echo web_url('application/merchant', array('op'=>'account_display'));}">可结算商家列表</a></li>
</ul>
{else}
<ul class="nav nav-tabs">
	<li {if $_GPC['op']=='account_display'}class="active"{/if}><a href="{php echo web_url('application/merchant', array('op'=>'account_display'));}">商家:    {$merchant['name']}</a></li>
</ul>
{/if}
{if $_GPC['op']=='account_display' || $_GPC['op']==''}
	<div class="panel panel-default">
		<div class="table-responsive">
			<table class="table table-hover" style="min-width: 300px;">
				<thead class="navbar-inner">
					<tr>
						<th class="col-sm-2">商家logo</th>
						<th class="col-sm-2">商家名称</th>
						<th class="col-sm-2">总成交金额</th>
						<th class="col-sm-2">可结算金额</th>
						<th class="col-sm-2">需上缴佣金</th>
						<th class="col-sm-2">佣金百分比</th>
						<th class="col-sm-5 text-center">操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $merchants $merchantid $merchant}
					<tr>
						<td><image src="{php echo tomedia($merchant['thumb']);}" style="max-width: 48px; max-height: 48px; border: 1px dotted gray"></td>
						<td>{$merchant['name']}</td>
						<td>{if $merchant['amount']}{$merchant['amount']}元{else}0.00元{/if}</td>
						<td>{if $merchant['no_money']}{$merchant['no_money']}元{else}0.00元{/if}</td>
						<td>{php echo $merchant['no_money']*$merchant['percent']*0.01;}元</td>
						<td>{if !empty($merchant['percent'])}{$merchant['percent']}%{else}0.00%{/if}</td>
						<td>
                     <a class="btn btn-default" href="{php echo web_url('application/merchant/account', array( 'id'=>$merchant['id']));}" title="去结算" class="btn btn-default btn-sm">去结算</a>
                    <a class="btn btn-default" href="{php echo web_url('application/merchant/record', array( 'id'=>$merchant['id']));}" title="结算记录" class="btn btn-default btn-sm">结算记录</a>
                    <a class="btn btn-default" href="{php echo web_url('application/merchant/data', array( 'id'=>$merchant['id']));}" title="订单统计" class="btn btn-default btn-sm">订单统计</a>
                   
						</td>
					</tr>
					{/loop}
					{if empty($merchants)}
					<tr>
						<td colspan="8">
							尚未添加商家
						</td>
					</tr>
					{/if}
				</tbody>
			</table>
			{$pager}
		</div>
	</div>
{elseif $_GPC['op']=='account'}
<div class="main">
	    <div class="panel panel-info">
	    <div class="panel-heading">结算注意</div>
	    <div class="panel-body">
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                1.可结算金额：客户收到货(核销)后该订单的钱才会转到可结算金额里。
                </label>
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                2.结算金额必须大于1元。
                </label>
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                3.请确认微信商户后台有足够的<font color="red" size="3">可用余额</font>。
                </label>
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                4.结算金额直接提现到该商家<font color="red" size="3">提现微信号</font>的<font color="red" size="3">微信钱包</font>中，<font color="red" size="3">注意绑定正确的微信号</font>，必要时可结算1元到该微信号上<font color="red" size="3">验证</font>是否绑定正确。
                </label>
	   		</div>
	    </div>
	</div> 
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
<div class="panel panel-default">
    <div class="panel-heading">
        结算
    </div>
    <div class="panel-body">
         <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">商家</label>
                <div class="col-sm-9 col-xs-12">
                    <img src="{php echo tomedia($merchant['thumb']);}" style="width:100px;height:100px;padding:1px;border:1px solid #ccc" onerror="">
                         {$merchant['name']}</div>
            </div>
         <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">总交易金额</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $account['amount']}{$account['amount']}元{else}0.00元{/if}</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">可结算金额</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $account['no_money']}{$account['no_money']}元{else}0.00元{/if}</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">佣金百分比</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $merchant['percent']}{$merchant['percent']}%{else}0.00%{/if}【到账金额 = 输入结算金额 - 输入结算金额 * 佣金百分比 ；到账金额必须大于1元！】</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">输入结算金额</label>
            <div class="col-sm-8 col-lg-3 col-xs-12">
                <input class="form-control" name="money" id="" type="text" value="{$_GPC['money']}" placeholder="">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
            <div class="col-sm-9 col-xs-12">
                    <input type="hidden" name="id" value="{$id}">
                    <input type="hidden" name="token" value="{$_W['token']}">
                    <input name="submit" type="submit" value="结 算" class="btn btn-primary span2" onclick="return confirm('确认结算？');return false;">
            </div>
           </div>
  
        </div>
    </div>
 
</form>
</div>
{elseif $_GPC['op']=='record'}
<div class="main">
    <div class="panel panel-info">
	    <div class="panel-body">
               <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">商家</label>
                <div class="col-sm-9 col-xs-12">
                    <img src="{php echo tomedia($merchant['thumb']);}" style="width:100px;height:100px;padding:1px;border:1px solid #ccc" onerror="">
                         {$merchant['name']}</div>
           		 </div>
            <!--<div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="text-align: right;padding-right: 30px;">导出订单</label>
            	<a href='{php echo $this->createWebUrl('order', array('op' => 'output','status'=>$status,'keyword'=>$keyword,'transid'=>$transid,'member'=>$member,'pay_type'=>$pay_type,'starttime'=>$starttime,'endtime'=>$endtime,'time'=>$time))}'>
            		<button class="btn btn-info"><i class="fa fa-download"></i> 导出订单</button>（如果按条件导出请先选择条件后查询，再导出。）
            	</a>
	   		</div>-->
	   		<!--<a href='{php echo $this->createWebUrl('order', array('op' => 'refundall'))}'><button class="btn btn-danger"><i class="fa fa-align-justify"></i> 一键退款</button></a>-->
	    </div>
	</div>

	<div class="panel panel-default">
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
					<tr>
						<th style="width:80px;">结算金额</th>
						<th style="width:80px;">结算人UID</th>
						<th style="width:80px;">结算日期</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $item}
					<tr>
						<td>{$item['money']}元</td>
						<td>{$item['uid']}</td>
						<td>{php echo date('Y-m-d H:i:s', $item['createtime'])}</td>
					</tr>
					{/loop}
				</tbody>
			</table>
		</div>
	</div>
</div>
{$pager}
<script type="text/javascript">
	require(['daterangepicker'], function($){
		$('.daterange').on('apply.daterangepicker', function(ev, picker) {
			$('#form1')[0].submit();
		});
	});
</script>


<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
{elseif $_GPC['op']=='data'}
<style type='text/css'>
       .trbody td {text-align: center; vertical-align:top;border-left:1px solid #ccc; border-bottom: 1px solid #ddd;}
</style>
<style>
	.order-rank img{width:16px; height:16px;}
	.js-remark,.js-admin-remark{word-break:break-all; overflow:hidden; background: #FDEEEE;color: #ED5050;padding: 5px 10px;}
	td.goods-info{position:relative; padding-left:60px;}
	.goods-info .img{position:absolute;top:50%; margin-top:-25px; background: url({IMAGE_LOADING}) center center no-repeat; width:50px;height:50px; }
	.goods-info span {white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: block;}
	.status-text{cursor:pointer;}
	.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {border-top: 1px solid rgba(221, 221, 221, 0);}
</style>
<ul class="nav nav-tabs">
	<li {if $op == 'data' && $status == '' }class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('id'=>$id))}">全部订单({$all})</a>
    </li>
    <li {if $op == 'data' && $status == '0'} class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('status' => 0,'id'=>$id))}">待付款({$status0})</a>
    </li>
	<li {if $op == 'data' && $status == '1'} class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('status' => 1,'id'=>$id))}">已付款({$status1})</a>
    </li>
	<li {if $op == 'data' && $status == '2'}class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('status' => 2,'id'=>$id))}">待使用({$status2})</a>
    </li>
	<li {if $op == 'data' && $status == '3'}class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('status' => 3,'id'=>$id))}">待收货({$status3})</a>
    </li>
	<li {if $op == 'data' && $status == '4'}class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('status' => 4,'id'=>$id))}">已完成({$status4})</a>
    </li>
    <li {if $op == 'data' && $status == '5'}class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('status' => 5,'id'=>$id))}">已取消({$status5})</a>
    </li>
    <li {if $op == 'data' && $status == '6'}class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('status' => 6,'id'=>$id))}">待退款({$status6})</a>
    </li>
    <li {if $op == 'data' && $status == '7'}class="active"{/if}>
        <a href="{php echo web_url('application/merchant/data', array('status' => 7,'id'=>$id))}">已退款({$status7})</a>
    </li>
	{if $op == 'detail'}
    <li class="active">
        <a href="#">订单详情</a>
    </li>
    {/if}
</ul>
<div class="main">
    <div class="panel panel-info">
	    <div class="panel-heading">筛选</div>
	    <div class="panel-body">
            <form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="lexiangpingou" />
                <input type="hidden" name="do" value="application" />
                <input type="hidden" name="ac" value="merchant" />
                <input type="hidden" name="op" value="data"/>
                <input type="hidden" name="status" value="{$status}"/>
                <input type="hidden" name="id" value="{$id}"/>
                <div class="form-group">
					<label class="col-md-4 col-lg-1 control-label">所属商家</label>
					<div class="col-md-4">
						<select name="merchantid" class="form-control">	
							<option value="">{$_W['account']['name']}</option>
						{loop $merchants $row}
				            <option value="{$row['id']}" {if $_GPC['merchantid']==$row['id']}selected="selected"{/if}>{$row['name']}</option>
						{/loop}}
				        </select>
					</div>
					 <label class="col-md-4 col-lg-1 control-label">商名称</label>
                    <div class="col-md-4">
                        <select name="goodsid2" class="form-control">
                            <option value="">--所有--</option>
                            {loop $allgoods $key $type}
                            <option value="{$type['id']}" {if $_GPC['goodsid2']==$type['id']}selected="selected"{/if}>{$type['gname']}</option>
                            {/loop}
                        </select>
                    </div>
				</div>
                <div class="form-group">
	            	<label class="col-md-4 col-lg-1 control-label">商品ID:</label>
	                <div class="col-md-4 control-label">
						<input type="text" name="goodsid" class="form-control" value="{$_GPC['goodsid']}" placeholder="可查询商品ID"/>
					</div>
					<label class="col-md-4 col-lg-1 control-label">订单号</label>
                    <div class="col-md-4">
                        <input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}" placeholder="可查询订单号">
                    </div>
                 </div>
                 <div class="form-group">
                    <label class="col-md-4 col-lg-1 control-label">微信订单</label>
                    <div class="col-md-4">
                        <input class="form-control" name="transid" id="" type="text" value="{$_GPC['transid']}" placeholder="微信订单号">
                    </div>
                     <label class="col-md-4 col-lg-1 control-label">用户信息</label>
                    <div class="col-md-4">
                        <input class="form-control" name="member" id="" type="text" value="{$_GPC['member']}" placeholder="可查询手机号 / 姓名">
                    </div>
                </div>
                <!--<div class="form-group">
                    <label class="col-md-4 col-lg-1 control-label">支付方式</label>
                    <div class="col-md-4">
                        <select name="pay_type" class="form-control">
                            <option value="">不限</option>
                            {loop $paytype $key $type}
                            <option value="{$key}" >{$type['name']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>-->
                <div class="form-group">
                        <label class="col-md-4 col-lg-1 control-label">下单时间</label>
                        <div class="col-sm-5 col-lg-7 col-xs-12">
                            {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:m:s', $starttime),'endtime'=>date('Y-m-d H:m:s', $endtime)),true);}
                        </div>
                        <div class="col-sm-3 col-lg-2" style="text-align:right;"><button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                        </div>
                    </div>
                <div class="form-group">
                </div>
            </form>
            <div class="form-group">
            	<a href='{php echo web_url('order/order/output', array('status'=>$status,'keyword'=>$keyword,'transid'=>$transid,'member'=>$member,'pay_type'=>$pay_type,'starttime'=>$starttime,'endtime'=>$endtime,'time'=>$time,'goodsid'=>$_GPC['goodsid'],'goodsid2'=>$_GPC['goodsid2'],'merchantid'=>$_GPC['merchantid']))}'>
            		<button class="btn btn-default"><i class="fa fa-download"></i> 导出订单</button>
            	</a>（如果按条件导出请先选择条件后查询，再导出。）
	   		</div>
	   		 <!--<div class="form-group">
                <label class="col-md-4 col-lg-1 control-label" style="text-align: right;padding-right: 30px;">数据统计</label>
				<a href='{php echo web_url('order/data/', array('status' => $status))}'><button class="btn btn-danger"><i class="fa fa-align-justify"></i> 数据统计</button></a>
	   		 </div>-->
	    </div>
	</div>
	<div class="order-list">
		<div class="panel-body table-responsive collapse in" id="order-template-item-4" style="padding: 0;">
			<table class="table table-bordered">
				<thead style="background-color: #FFFFFF;">
					<tr>
						<!--<th style="width:60px;" class="text-center"><input type="checkbox" onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" />全选</th>-->
						<th style="width:220px;">商品</th>
						<th style="width:80px; text-align:center;">单价/数量</th>
						<th style="width:80px; text-align:center;">所属商家</th>
						<th style="width:100px; text-align:center;">买家</th>
						<th style="width:110px; text-align:center;">下单时间</th>
						<th style="width:120px; text-align:center;">订单状态</th>
						<th style="width:130px; text-align:center;">金额</th>
					</tr>
				</thead>
				
			</table>
		</div>
		{loop $list $item}
		<div class="panel panel-default">
			<div class="panel-heading clearfix" style="padding: 10px 15px;">
				<div class="pull-left">
					{if $item['is_tuan']==1 || $item['is_tuan']==3}
					<a href="{php echo web_url('order/group/group_detail', array('groupnumber' => $item['tuan_id']))}">
					<span class="label label-warning">拼团单：{$item['tuan_id']}号</span></a>
					{elseif $item['is_tuan']==0}
					<a href="{php echo web_url('order/order/detail', array( 'id' => $item['id'],'is_tuan'=>1))}">
					<span class="label label-success">直购单</span>
					</a>
					{elseif $item['is_tuan']==2}
										<a href="{php echo web_url('order/group/group_detail', array('groupnumber' => $item['tuan_id']))}"><span class="label label-default">团满退款单</span></a>
					{/if}
					<b>订单号: {$item['orderno']}</b>
				</div>
				<div class="pull-right">
					<span class="text-muted"></span>&nbsp;&nbsp;
					<a href="{php echo web_url('order/order/detail', array('id' => $item['id']))}" target="_blank">查看详情</a> -
					<a href="javascript:;" class="js-order-edit-remark" order-id="{$item['id']}">备注</a>
				</div>
			</div>
			<div class="panel-body table-responsive" style="padding: 0px;">
				<table class="table table-bordered">
					<tbody>
						<tr>
							<!--<td class="text-center" style="width:60px;"><input type="checkbox" name="checkbox[]"  value="{$item['id']}" /></td>-->
							<td class="goods-info line-feed" style="width:220px;padding-left: 10px;">
								<div class="img"><img width="50" height="50" class="oscrollLoading" src="{IMAGE_PIXEL}" data-url="{php echo tomedia($item['gimg'])}" height="50" width="50" onerror="this.src='{IMAGE_NOPIC_SMALL}'" ></div>
								<div class="title" style="padding-left: 60px;">
									<span>{$item['gname']}</span>
									<p class="text-muted">{if $item['optionname']}规格  ：  {$item['optionname']}{/if}</p>
								</div>
							</td>
							<td class="text-center" style="width:80px;">
								<p>{$item['goodsprice']}</p>
								<p>({$item['gnum']} {$item['unit']})</p>
							</td>
							<td class="text-center" style="width:80px;">{if empty($item['merchant']['name'])}{$_W['account']['name']}{else}{$item['merchant']['name']}{/if}</td>
							<td class="text-center" style="width:100px;">
								<p>{if $item['cname']}{$item['cname']}{else}{$item['addname']}{/if}</p>
								<p>{if $item['tel']}{$item['tel']}{else}{$item['mobile']}{/if}</p>
							</td>
							<td class="text-center" style="width:110px;">{php echo date('Y-m-d', $item['createtime'])}<br>{php echo date('H:i:s', $item['createtime'])}</td>
							<td class="text-center" style="width:120px;">
								<span class="label label-{$item['statuscss']}">{$item['status']}</span>
							</td>
							<td class="text-center" style="width:130px;">总额：{if empty($item['price'])}0.00{else}{$item['price']}{/if}元<br>实付：{if empty($item['pay_price'])}{$item['price']}{else}{$item['pay_price']}{/if}元<br>（含运费：{$item['freight']}）</td>
						</tr>
					</tbody>
				</table>
			</div>
			
			<div  class="panel-footer js-remark" {if empty($item['remark'])}style="display: none;"{/if} style="background-color:#28A54C">
				买家备注:{$item['remark']}	
			</div>
			<div class="panel-footer js-admin-remark{$item['id']} " order-id="{$item['id']}" {if empty($item['adminremark'])}style="display: none;"{/if} style="background-color:lightgoldenrodyellow">
				卖家备注：<span id="js-admin-remark{$item['id']}" style="">{$item['adminremark']}</span>
			</div>
		</div>
		{/loop}
	</div>
	{$pager}
</div>
<script type="text/javascript">
require(['daterangepicker'], function($){
	$('.daterange').on('apply.daterangepicker', function(ev, picker) {
		$('#form1')[0].submit();
	});
});

	$(function(){
		$('[name="rank_all"]').click(function() {
			var checked = this.checked;
			$('.js-rank').find('input:checkbox').each(function() {
				this.checked = checked;
			});
		});
		$('#export').click(function() {
			if ($('[name="selecttime[start]"]').val() == '') {
				util.tips('请选择下单时间');
				$(this).focus();
				return false;
			};
			$(this).attr('type', 'submit').submit();
		});
		
		$('.order-rank').each(function(){
			o.rank(this);
		});
		
		$(".oscrollLoading").scrollLoading();
		var $pop = null;
		$('.goods-info').hover(function() {
			var obj = this;
			var img = $(this).find('img').attr('src');
			var $pop = util.popover(obj, function($popover, obj) {
				obj.$popover = $popover;
			}, '<div><img src="'+ img+'" style="max-width:200px; max-height:200px;"></div>');
		}, function() {
			this.$popover.remove();
		});

		$('.js-order-status').delegate('.status-text', 'mouseover mouseout', function(event){
			var obj = this;
			if (event.type == 'mouseover'){
				var $pop = util.popover(obj, function($popover, obj) {obj.$popover = $popover;}, {html: '<span>'+$(obj).data('title')+'</span>', placement : 'top'});
			} else {
				this.$popover.remove();
			}
		});

		$('.js-order-status').delegate('.express', 'mouseover mouseout', function(event){
			var obj = this;
			if (event.type == 'mouseover'){
				var $pop = util.popover(obj, function($popover, obj) {obj.$popover = $popover;}, {html: '<p class="mb0">物流公司：'+$(obj).data('express')+'</p><p class="mb0">物流单号：'+$(obj).data('express-no')+'</p>', placement : 'top'});
			} else {
				this.$popover.remove();
			}
		});
		
		// 修改备注
		$('.js-order-edit-remark').click(function() {
			var order_id = $(this).attr('order-id');
			$('.js-order-remark-post').attr("order-id",order_id);
			$('#order-remark-container').show();
			$('.main').css("opacity","0.2");$('.nav').css("opacity","0.2");$('.big-menu').css("opacity","0.2");
		});
		$('.js-cancel,.close').click(function() {
			$('#order-remark-container').hide();
			$('.main').css("opacity","1");$('.nav').css("opacity","1");$('.big-menu').css("opacity","1");
		});
		$('.js-order-remark-post').click(function() {
			var order_id = $(this).attr('order-id');
			var remark = $('#remark').val();
			$.post("{php echo web_url('order/order/remark')}",{id:order_id,remark:remark},function(d){
				if(!d.errno){
					$('#js-admin-remark'+order_id).html(remark);
					$('.js-admin-remark'+order_id).show();
				}
			},"json");
			$('#order-remark-container').hide();
			$('.main').css("opacity","1");$('.nav').css("opacity","1");$('.big-menu').css("opacity","1");
		});
		
		// 修改价格
		$('.js-order-edit-payment').click(function() {
			var $this = $(this);
			var order_id = $this.attr('order-id');
			
			o.editPayment(order_id, function(order) {
				$this.parent()
					.find('.js-order-payment').find('.js-fee').html(order.payment).end().end()
					.find('.js-order-post-fee').find('.js-fee').html(order.post_fee);
				
				var adjust_fee = parseFloat(order.adjust_fee);
				if (adjust_fee){
					var title = adjust_fee > 0 ? '加价' : '减价';
					console.log(title);
					$this.parent()
						.find('.js-order-adjust-fee').show()
						.find('.js-title').text(title).end()
						.find('.js-fee').text(adjust_fee.toFixed(2));
				} else {
					$this.parent()
						.find('.js-order-adjust-fee').hide()
						.find('.js-title').text('').end()
						.find('.js-fee').text('');
				}
			});
		});
		
		// 取消订单
		$('.order-list').delegate('.js-order-cancel', 'click', function(){
			var $this = $(this);
			var order_id = $this.attr('order-id');
			o.adminClose(order_id, function(order){
				console.log(order);
				$this.parent().parent().find('.status-text').text(order.status_text).data('title', order.status_content + '<br/>关闭原因:' + order.cancel_reason);
				$this.remove();
			});
		});
		
		//发货
		$('.order-list').delegate('.js-order-send', 'click', function(){
			var $this = $(this);
			var order_id = $this.attr('order-id');
			o.send(order_id, function(order) {
				$this.parent().parent()
					.append($('<p class="express b">物流信息</p>').data('express', order.express_company).data('express-no', order.express_no))
					.find('.status-text').text(order.status_text).data('title', order.status_content);
				$this.remove();
			});
		});
		//删除
		$('.order-list').delegate('.js-remove', 'click', function(e){
			e.stopPropagation();
			var $this = $(this);
			var id = $this.attr('order-id');
			util.nailConfirm(this, function(state) {
				if(!state) return;
				$.post("{php echo url('order/order/delete');}", { id : id }, function(data){
					if(!data.errno){
						$this.parent().parent().parent().parent().remove();
					};
					util.tips(data.message);
				}, 'json');
			}, {html: '确认删除?'});
		});
	});

</script>
{/if}
{php include wl_template('common/footer');}